Skip to content

fix: dualaxes brushfilter change y axis#7284

Open
moayuisuda wants to merge 1 commit intov5from
fix/brush
Open

fix: dualaxes brushfilter change y axis#7284
moayuisuda wants to merge 1 commit intov5from
fix/brush

Conversation

@moayuisuda
Copy link
Copy Markdown
Collaborator

Checklist
  • npm test passes
Description of change

#7272

image

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the BrushFilter interaction in src/interaction/brushFilter.ts to prevent overriding the y-scale domain for marks with independent y-scales, thereby avoiding cross-scale domain pollution. A review comment suggests making the detection of independent scales more robust by checking for scale keys in addition to the independent flag, potentially utilizing existing utility functions for consistency.

const newMarks = marks.map((mark) => {
// Independent y scale manages its own domain based on filtered data,
// so skip overriding it to avoid cross-scale domain pollution.
const isYIndependent = mark.scale?.y?.independent === true;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current logic to detect an independent Y scale only checks for independent: true. This is correct, but might be incomplete. The codebase has other ways to define independent scales, for example by using different key properties on the scale.

To make this fix more robust and align with other parts of the codebase (like hasIndependentXYScale in utils.ts), consider also checking for scale keys. This would handle cases where dual axes are defined by keys without explicitly setting independent: true.

For example, you could modify the logic like this:

// At the top of the file:
import { hasIndependentXYScale } from './utils';

// ...

// Inside setState, before mapping marks:
const hasMultiYScales = hasIndependentXYScale('y', marks);

// ...

// Inside map, replace the isYIndependent check:
const isYIndependent =
  mark.scale?.y?.independent === true ||
  (hasMultiYScales && !!mark.scale?.y?.key);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant